<template>
    <div>

        <h3>日志一览</h3>
        <el-table
                :data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)"
                style="width: 100%">
            <el-table-column
                    label="日期"
                    prop="createdate">
            </el-table-column>
            <el-table-column
                    label="内容"
                    prop="contents">
            </el-table-column>
        </el-table>
        <div class="tabListPage">
            <el-pagination @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="currentPage"
                           :page-sizes="pageSizes"
                           :page-size="PageSize" layout="total, sizes, prev, pager, next, jumper"
                           :total="totalCount">
            </el-pagination>
        </div>

        <div style="width:600px; height: 400px; border: 2px solid;">
            <span>--查询日志信息--</span>

            <el-form ref="logForm">
                <el-row>
                    <el-form-item label="起始时间：" prop="startDate">
                        <el-input v-model="startDate"></el-input>
                    </el-form-item>
                </el-row>
                <el-row style="margin-top: 10px">
                    <el-form-item label="结束时间：" prop="endDate">
                        <el-input v-model="endDate"></el-input>
                    </el-form-item>
                </el-row>
            </el-form>
            <el-button @click="findByItem('logForm')">查询</el-button>
        </div>

    </div>
</template>

<script>
    export default {
        name: "LogView",

        data() {
            return {
                totalCount:null,

                // 默认显示第几页
                currentPage:1,
                // 个数选择器（可修改）
                pageSizes:[1,2,3,4],
                // 默认每页显示的条数（可修改）
                PageSize:3,
                startDate: '',
                endDate: '',
                tableData: [],
                search: ''
            }
        },
        mounted() {
            this.findByItem()
        },
        methods: {
            findByItem(){

                this.$axios.get("api/loginlog/findByItem?startDate="
                    +this.startDate+"&endtDate="+this.endDate).then(r =>{

                    console.log(r.data);
                    this.tableData = r.data;
                })
            },

            handleSizeChange(size) {
                // 改变每页显示的条数
                this.PageSize=size
                // 注意：在改变每页显示的条数时，要将页码显示到第一页
                this.currentPage=1
            },
            // 显示第几页
            handleCurrentChange(size) {
                // 改变默认的页数
                this.currentPage=size
            },

        },
    }
</script>

<style scoped>

</style>